<template>
  <div class="cartsmain1">
    <div v-for="item in carts">
      {{ item.id }} {{ item.title }}
      <button @click="setCartsBuyNumFn">购买</button>
    </div>
  </div>
</template>

<script>
import { mapActions, mapState, mapMutations} from "vuex";
export default {
  computed: {
    ...mapState({
      carts: (state) => state.carts.carts,
    }),
  },
  methods: {
    ...mapActions({
      setCartsFn: "carts/setCarts",
    }),
    ...mapMutations({
        setCartsBuyNumFn:"carts/setCartsBuyNum"
    })
  },
  created() {
    this.setCartsFn();
  },
};
</script>

<style lang="scss">
</style>